<template>
<Modal v-model="modalEdit" fullscreen @on-cancel="handleModalEditCancel">
	<template #header>
		<Icon custom="iconfont icon-Word"/>&nbsp;简易程序行政处罚决定书&nbsp;
	</template>
	<template #footer><Space>
		<Button shape="circle" @click="handleModalEditCancel">取消</Button>
		<Button type="primary" shape="circle" @click="handleModalEditOK">提交</Button>
	</Space></template>
	<div><Row justify="center"><Col span="16"><Form ref="baseform" :model="baseform" :rules="ruleValidate" :label-width="150">
		<Card title="案件情况" icon="ios-bookmark">
			<template #extra>
				提交日期：<DatePicker v-model="baseform.date4" type="date" placeholder="选择日期" style="width: 200px"/>&nbsp;&nbsp;
				{{baseform.party_name}}&nbsp;涉嫌&nbsp;{{baseform.cause_name}}
			</template>
			<FormItem label="*违法时间：" prop="time1" required><Space>
				<DatePicker v-model="baseform.date1" type="date" placeholder="选择日期" style="width: 200px" />
				<TimePicker format="HH:mm" v-model="baseform.time1" placeholder="选择时间" style="width: 112px" />
			</Space></FormItem>
			<FormItem label="*责令改正：" prop="correct">
				<RadioGroup v-model="baseform.correct">
					<Space direction="vertical">
						<Radio label="立即改正" border></Radio>
						<Radio label="限期改正" border></Radio>
						<div v-if="baseform.correct==='限期改正'">
							改正截至日期： <DatePicker v-model="baseform.date2" type="date" placeholder="输入日期" style="width: 200px"/><br>
						</div>
					</Space>
				</RadioGroup>
			</FormItem>
			<FormItem label="*处罚：" prop="punish" required>
				<RadioGroup v-model="baseform.punish">
					<Space direction="vertical">
						<Radio label="警告" border></Radio>
						<Radio label="罚款" border></Radio>
						
					</Space>
					<div v-if="baseform.punish==='罚款'"><Space direction="vertical">
						罚款金额：<Input v-model="baseform.amount" prefix="logo-yen" placeholder="输入金额" style="width: 200px" />
						罚款的履行方式和期限：
						<RadioGroup v-model="baseform.perform">
							<Space direction="vertical">
								<Radio label="当场收缴" border></Radio>
								<Radio label="限期收缴" border></Radio>
								<div v-if="baseform.perform==='限期收缴'">
									收缴截至日期： <DatePicker v-model="baseform.date3" type="date" placeholder="输入日期" style="width: 200px"/><br>
								</div>
							</Space>
						</RadioGroup>
					</Space></div>
				</RadioGroup>
			</FormItem>
			<FormItem label="*协办人：" prop="uid2" required>
				<Select v-model="baseform.uid2" style="width:150px" filterable @on-select="handleSelectLegal2">
					<Option v-for="item in legals" :value="item.uid" :key="item.uid">{{ item.uname }}</Option>
				</Select>&nbsp;
			</FormItem>
		</Card>
	</Form></Col></Row></div>
</Modal>
</template>

<script>
import {dateUtils,appendDoc} from '@/libs/tools.js'
import config from '@/config'
export default{
	data(){
		return {
			modalEdit:true,
			legals:[],
			ruleValidate:{
				time1: [{ required: true, message: '请输入违法时间'}],
				correct: [{ required: true, message: '请输入责令改正'}],
				punish: [{ required: true, message: '请输入处罚'}],
				uid2: [{ required: true, message: '请输入协办人'}]
			},
			baseform:{}
		}
	},
	methods:{
		handleModalEditCancel(){
			this.$router.go(-1)
		},
		handleSelectLegal2(n){
			this.baseform.uid2=n.value
			this.baseform.legal_name2=n.label//用于数据库保存
			this.baseform.legal2_name=n.label//用于生成文书
		},
		handleModalEditOK(){
			let data={...this.baseform}
			data.date1=dateUtils.format2(data.date1)
			data.date2=dateUtils.format2(data.date2)
			data.date3=dateUtils.format2(data.date3)
			data.date4=dateUtils.format2(data.date4)
			data.docs=appendDoc(data.docs,"doc128")
			console.info(data)
			this.$refs.baseform.validate((valid) => {
				if (valid) {
					this.$axios.post('mainCase1CreateDoc128.action',data).then(res=>{
						window.open(config.baseUrl+res.data,'_blank')
						this.modalEdit=false
						this.$router.go(-1)
					})
				}
			})			
		}
	},
	mounted(){
		this.$axios.post('mainCase1GetDoc128.action',{
			case_no:this.$route.query.case_no,
			party_type:this.$route.query.party_type
		}).then(res=>{
			this.baseform={...this.baseform,...res.data}
		})
		this.$axios.post('mainCase2GetDoc1802Legals.action',{}).then(res=>{
			this.legals=res.data
		})
	}
}
</script>

<style>
</style>